package com.beiye.drivertransport.SubActivity;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.beiye.drivertransport.R;
import com.beiye.drivertransport.activity.TwoBaseAty;
import com.beiye.drivertransport.adapter.MyGridViewAdapter;
import com.beiye.drivertransport.bean.LearnRecordBean;
import com.beiye.drivertransport.bean.LoginUserBean;
import com.beiye.drivertransport.http.Login;
import com.beiye.drivertransport.utils.UserManger;
import com.beiye.drivertransport.utils.Utils;
import com.beiye.drivertransport.view.ShowGridView;
import com.githang.statusbar.StatusBarCompat;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import butterknife.OnClick;
import okhttp3.Call;
import okhttp3.Response;
//学习记录界面
public class SubLearnRecordActivity extends TwoBaseAty {


    ImageView img_recordback;

    ExpandableListView record_lv;

    TextView tv_record;
//    @Bind(R.id.img_record)
//    TextView img_down;//down

    View empty_view;

    private MyExpandableListViewAdapter adapter;
//    private PopWindowApt popWindowApt;
//    private PopupWindow mPopWindow;

    @Override
    public int getLayoutId() {
        return R.layout.activity_sub_learn_record;
    }

    public void onClick(View view) {
        if (view.getId() == R.id.img_recordback) {//返回首页
            finish();
            //            case R.id.tv_record://弹框就可以选公司
//
//                if(popWindowApt==null||popWindowApt.getCount()==1)
//                {
//
//                    return;
//                }else{
//
//                    showPopupWindow();
//                }
//                break;
        }

    }

    @Override
    public void initData() {
        img_recordback = (ImageView) findViewById(R.id.img_recordback);
        record_lv = (ExpandableListView) findViewById(R.id.record_expandablelistview);
        tv_record = (TextView) findViewById(R.id.tv_record);
        empty_view = (View) findViewById(R.id.empty_view);
        StatusBarCompat.setStatusBarColor(this, Color.parseColor("#1F80C4"));
        //选中公司方法
           initCompany();
  //      readintervalData();
           initUi();
    }

    private void initUi() {
        record_lv.setGroupIndicator(null);//去掉箭头
        record_lv.setEmptyView(empty_view);
        record_lv.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
            @Override
            public boolean onChildClick(ExpandableListView expandableListView, View view, int groupPosition, int childPosition, long l) {

                return true;
            }
        });
    }
    private void initCompany() {
//        LoginUserBean userInfo = UserManger.getUserInfo();
//        LoginUserBean.DataBean data = userInfo.getData();
//        if(data==null)
//        {
//            return;
//        }
//        List<LoginUserBean.DataBean.CurUserOrgBean> curuserOrglist = data.getCur_userOrg();
//        if(curuserOrglist.size()==0)
//        {
//            img_down.setVisibility(View.INVISIBLE);
//            return;
//        }
//        String orgName = curuserOrglist.get(0).getOrgName();
//        String orgId = curuserOrglist.get(0).getOrgId();
//        int minPer = curuserOrglist.get(0).getMinPer();
//        int pjtMinPer = curuserOrglist.get(0).getPjtMinPer();
//        int photoMark = curuserOrglist.get(0).gettPhotoMark();
//        int signMark = curuserOrglist.get(0).gettSignMark();

        Bundle bundle = getIntent().getExtras();
        int pjtMinPer= bundle.getInt("pjtMinPer");
        int minPer = bundle.getInt("minPer");
        int signMark = bundle.getInt("signMark");
        int photoMark = bundle.getInt("photoMark");
        String orgId = bundle.getString("orgId");
        String orgName = bundle.getString("orgName");

        tv_record.setText(orgName);
        //orgId
        SharedPreferences sp = getSharedPreferences("orgId101",
                Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putString("orgId",orgId);
        editor.putInt("minPer",minPer);
        editor.putInt("pjtMinPer",pjtMinPer);
        editor.putInt("photoMark",photoMark);
        editor.putInt("signMark",signMark);
        editor.commit();
        requestData();
//        popWindowApt = new PopWindowApt(SubLearnRecordActivity.this,curuserOrglist,R.layout.popwindow_item_layout);
//        if(popWindowApt.getCount()==1)
//        {
//            img_down.setVisibility(View.INVISIBLE);
//        }else{
//            img_down.setVisibility(View.VISIBLE);
//        }

    }
//    private void showPopupWindow() {
//        //设置contentView
//        View contentView = LayoutInflater.from(SubLearnRecordActivity.this).inflate(R.layout.popwindow_layout, null);
//        mPopWindow = new PopupWindow(contentView,
//                WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true);
//        //设置各个控件的点击响应
//        ListView lv_company = (ListView)contentView.findViewById(R.id.lv_company);
//        lv_company.setAdapter(popWindowApt);
//          mPopWindow.showAtLocation(tv_record, Gravity.CENTER, 0, 0);
//        lv_company.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
//                if(popWindowApt!=null)
//                {
//
//                    String orgName = popWindowApt.getItem(position).getOrgName();
//                    String orgId = popWindowApt.getItem(position).getOrgId();
//                    int minPer = popWindowApt.getItem(position).getMinPer();
//                    int pjtMinPer = popWindowApt.getItem(position).getPjtMinPer();
//                    int photoMark = popWindowApt.getItem(position).gettPhotoMark();
//                    int signMark = popWindowApt.getItem(position).gettSignMark();
//                    mPopWindow.dismiss();
//                    tv_record.setText(orgName);
//                    //orgId
//                    SharedPreferences sp = getSharedPreferences("orgId101",
//                            Context.MODE_PRIVATE);
//                    SharedPreferences.Editor editor = sp.edit();
//                    editor.putString("orgId",orgId);
//                    editor.putInt("minPer",minPer);
//                    editor.putInt("pjtMinPer",pjtMinPer);
//                    editor.putInt("photoMark",photoMark);
//                    editor.putInt("signMark",signMark);
//                    editor.commit();
//                    requestData();
//
//
//                }
//            }
//        });
//    }


//    public void initUiData(String orgId) {
//        LoginUserBean userInfo = UserManger.getUserInfo();
//        String userId = userInfo.getUserId();
//
////        //存储一份readInterval文件
////        SharedPreferences sp = getSharedPreferences("readInterval",
////                Context.MODE_PRIVATE);
////        int  readInterval = sp.getInt("readInterval", 0);
////        //存储一份orgId文件
////        SharedPreferences spp = getActivity().getSharedPreferences("orgId1",
////                Context.MODE_PRIVATE);
////        String  orgId = spp.getString("orgId","");
//        new Login().getrRecordLearning(userId,this,1);
//
//    }
    @Override
    public void onSuccess(String result, Call call, Response response, int what) {
        if(what==1)
        {
           // dialog.dismiss();
            Map<LearnRecordBean.RowsBean, List<LearnRecordBean.RowsBean.ListCourseBean>> dataset = new HashMap<>();
            LearnRecordBean learnRecordBean = JSON.parseObject(result, LearnRecordBean.class);
           List<LearnRecordBean.RowsBean> rows = learnRecordBean.getRows();
            for (int i= 0;i< rows.size();i++) {
                List<LearnRecordBean.RowsBean.ListCourseBean> listCourse = rows.get(i).getListCourse();
                dataset.put(rows.get(i),listCourse);
            }
            adapter = new MyExpandableListViewAdapter(SubLearnRecordActivity.this,rows,dataset);
            record_lv.setAdapter(adapter);


        }
        super.onSuccess(result, call, response, what);
    }



    @Override
    public void requestData() {

        LoginUserBean userInfo = UserManger.getUserInfo();
        LoginUserBean.DataBean data = userInfo.getData();
        if(data==null)
        {
            return;
        }
        String userId = data.getUserId();
        SharedPreferences sp = getSharedPreferences("orgId101",
                Context.MODE_PRIVATE);
        String orgId = sp.getString("orgId", "");
      //  dialog = CustomProgressDialog.show(SubLearnRecordActivity.this, "", true, null);
        showLoadingDialog("正在加载");
        new Login().getrRecordLearning(userId,orgId,this,1);


    }

    @Override
    protected void onResume() {
        super.onResume();
        //从新刷新数据
        LoginUserBean userInfo = UserManger.getUserInfo();
        LoginUserBean.DataBean data = userInfo.getData();
        if(data==null)
        {
            return;
        }
        String userId = data.getUserId();
        SharedPreferences sp = getSharedPreferences("orgId101",
                Context.MODE_PRIVATE);
        String orgId = sp.getString("orgId", "");
        //  dialog = CustomProgressDialog.show(SubLearnRecordActivity.this, "", true, null);
//        showLoadingDialog("正在加载");
        new Login().getrRecordLearning(userId,orgId,this,1);

    }

    private class MyExpandableListViewAdapter extends BaseExpandableListAdapter {
        private  Context context;
        private  List<LearnRecordBean.RowsBean> rows;
        private   Map<LearnRecordBean.RowsBean, List<LearnRecordBean.RowsBean.ListCourseBean>> dataset;
        public MyExpandableListViewAdapter(Context context, List<LearnRecordBean.RowsBean> rows, Map<LearnRecordBean.RowsBean, List<LearnRecordBean.RowsBean.ListCourseBean>> dataset) {
            this.context = context;
            this.rows = rows;
            this.dataset = dataset;
        }
        //  获得某个父项的某个子项
        @Override
        public Object getChild(int parentPos, int childPos) {
            return dataset.get(rows.get(parentPos)).get(childPos);
        }

        //  获得父项的数量
        @Override
        public int getGroupCount() {
            return dataset.size();
        }

        //  获得某个父项的子项数目
        @Override
        public int getChildrenCount(int parentPos) {
            return dataset.get(rows.get(parentPos)).size();
        }

        //  获得某个父项
        @Override
        public Object getGroup(int parentPos) {
            return dataset.get(rows.get(parentPos));
        }

        //  获得某个父项的id
        @Override
        public long getGroupId(int parentPos) {
            return parentPos;
        }

        //  获得某个父项的某个子项的id
        @Override
        public long getChildId(int parentPos, int childPos) {
            return childPos;
        }

        //  按函数的名字来理解应该是是否具有稳定的id，这个方法目前一直都是返回false，没有去改动过
        @Override
        public boolean hasStableIds() {
            return false;
        }

        //  获得父项显示的view
        @Override
        public View getGroupView(int parentPos, boolean b, View view, ViewGroup viewGroup) {
            if (view == null) {
                LayoutInflater inflater = (LayoutInflater) SubLearnRecordActivity.this
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = inflater.inflate(R.layout.record_parent_item, null);
            }
            view.setTag(R.layout.record_parent_item, parentPos);
            view.setTag(R.layout.record_child_item, -1);
            ImageView img_parent =(ImageView) view.findViewById(R.id.img_parent);
            TextView tv_chName =(TextView) view.findViewById(R.id.tv_parent);//学时名称
            TextView tv_creationDate =(TextView) view.findViewById(R.id.tv_parent3);//开始日期
            TextView tv_timesum =(TextView) view.findViewById(R.id.tv_parent2);//学时
            TextView tv_ChLength =(TextView) view.findViewById(R.id.tv_parent6);//设定时长与实际时长
            ImageView tv_comple =(ImageView) view.findViewById(R.id.tv_parent4);//完成
            ImageView tv_complesign =(ImageView) view.findViewById(R.id.tv_parent8);//完成签名
            ImageView tv_Notthrough =(ImageView) view.findViewById(R.id.tv_parent5);//未通过
            ImageView tv_checktgrough =(ImageView) view.findViewById(R.id.tv_parent7);//抽查通过
            TextView record_parent_line =(TextView) view.findViewById(R.id.record_parent_line);
            TextView record_parent_sign =(TextView) view.findViewById(R.id.tv_parent9);//签名按钮
            RelativeLayout re_des =(RelativeLayout) view.findViewById(R.id.re_des);
            TextView tv_des =(TextView) view.findViewById(R.id.tv_des);//审核描述
            ShowGridView gv_parent =(ShowGridView) view.findViewById(R.id.gv_parent);
            LinearLayout re_nodata =(LinearLayout) view.findViewById(R.id.re_nodata);//子类无数据
            gv_parent.setClickable(false);
            gv_parent.setPressed(false);
            gv_parent.setEnabled(false);
      //      LinearLayout.LayoutParams linearParams =(LinearLayout.LayoutParams) record_parent_line.getLayoutParams(); //取控件textView当前的布局参数
       final LearnRecordBean.RowsBean rowsBean = rows.get(parentPos);
            long creationDate = rowsBean.getCreationDate();
            String begin="";
            try {
                //yyyy表示年MM表示月dd表示日
                //yyyy-MM-dd是日期的格式，比如2015-12-12如果你要得到2015年12月12日就换成yyyy年MM月dd日
                SimpleDateFormat sdf=new SimpleDateFormat("yyyy/MM/dd");
                //进行格式化
                begin=sdf.format(creationDate);
            } catch (Exception e) {
                e.printStackTrace();
            }
            tv_creationDate.setText("最近学习时间: "+begin);

                tv_timesum.setText(rowsBean.getChNo()+"学时");
                tv_ChLength.setText(rowsBean.getActualChLength()+"分钟/"+rowsBean.getSetChLength()+"分钟");

            if(rowsBean.getPjtMark()==1)//岗前培训
            {
                tv_chName.setText("岗前培训 · "+rowsBean.getChName());
                if(rowsBean.getCheckMark()==2)
                {
                    tv_Notthrough.setVisibility(View.VISIBLE);
                    tv_Notthrough.setImageResource(R.mipmap.bj_21);
                    tv_comple.setImageResource(R.mipmap.bj_11);
                    tv_complesign.setVisibility(View.VISIBLE);
                    record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                    final      String signPicUrl = rowsBean.getSignPicUrl();
                    if(signPicUrl==null)
                    {
                        tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                        record_parent_sign.setText("签名");
                        record_parent_sign.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                if (Utils.isFastDoubleClick()) {
                                    return;
                                }
                                int sn =rowsBean.getSn();
                                Bundle bundle = new Bundle();
                                bundle.putInt("sn", sn);
                                bundle.putString("signPicUrl", "");
                                startActivity(SignActivity.class, bundle);

                            }
                        });

                    }else{
                        tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                        record_parent_sign.setText("查看签名");
                        record_parent_sign.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                if (Utils.isFastDoubleClick()) {
                                    return;
                                }
                                int sn =rowsBean.getSn();
                                Bundle bundle = new Bundle();
                                bundle.putInt("sn", sn);
                                bundle.putString("signPicUrl", signPicUrl);
                                startActivity(SignActivity.class, bundle);
                            }
                        });
                    }
                }else if(rowsBean.getCheckMark()==1)
                {
                    tv_Notthrough.setVisibility(View.VISIBLE);
                    tv_Notthrough.setImageResource(R.mipmap.bj_09);
                    tv_comple.setImageResource(R.mipmap.bj_11);
                    tv_complesign.setVisibility(View.VISIBLE);
                    record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                    final      String signPicUrl = rowsBean.getSignPicUrl();
                    if(signPicUrl==null)
                    {
                        tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                        record_parent_sign.setText("签名");
                        record_parent_sign.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                if (Utils.isFastDoubleClick()) {
                                    return;
                                }
                                int sn =rowsBean.getSn();
                                Bundle bundle = new Bundle();
                                bundle.putInt("sn", sn);
                                bundle.putString("signPicUrl", "");
                                startActivity(SignActivity.class, bundle);
                            }
                        });
                    }else{
                        tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                        record_parent_sign.setText("查看签名");
                        record_parent_sign.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                if (Utils.isFastDoubleClick()) {
                                    return;
                                }
                                int sn =rowsBean.getSn();
                                Bundle bundle = new Bundle();
                                bundle.putInt("sn", sn);
                                bundle.putString("signPicUrl", signPicUrl);
                                startActivity(SignActivity.class, bundle);
                            }
                        });
                    }
                }else if(rowsBean.getCheckMark()==0)
                {


                    if(rowsBean.getFinishMark()==1)
                    {
                        tv_comple.setImageResource(R.mipmap.bj_11);
                        tv_Notthrough.setVisibility(View.VISIBLE);
                        tv_Notthrough.setImageResource(R.mipmap.bj_03);
                        tv_complesign.setVisibility(View.VISIBLE);
                        tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                        record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                        record_parent_sign.setText("签名");

                        record_parent_sign.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                if (Utils.isFastDoubleClick()) {
                                    return;
                                }
                                int sn =rowsBean.getSn();
                                Bundle bundle = new Bundle();
                                bundle.putInt("sn", sn);
                                bundle.putString("signPicUrl", "");
                                startActivity(SignActivity.class, bundle);
                            }
                        });

                    }else if(rowsBean.getFinishMark()==2)
                    {
                        tv_comple.setImageResource(R.mipmap.bj_11);
                        tv_Notthrough.setVisibility(View.VISIBLE);
                        tv_Notthrough.setImageResource(R.mipmap.bj_03);
                        tv_complesign.setVisibility(View.VISIBLE);
                        tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                        record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                        record_parent_sign.setText("查看签名");
                        record_parent_sign.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                if (Utils.isFastDoubleClick()) {
                                    return;
                                }
                                int sn =rowsBean.getSn();
                                String signPicUrl = rowsBean.getSignPicUrl();
                                Bundle bundle = new Bundle();
                                bundle.putInt("sn", sn);
                                bundle.putString("signPicUrl", signPicUrl);
                                startActivity(SignActivity.class, bundle);
                            }
                        });

                    }
                    else if(rowsBean.getFinishMark()==0)
                    {
                        tv_comple.setImageResource(R.mipmap.bj_23);
                        tv_Notthrough.setVisibility(View.GONE);
                        tv_complesign.setVisibility(View.GONE);
                        record_parent_sign.setVisibility(View.GONE);

                    }
                }
            }else{//安全学习

                int chType = rowsBean.getChType();
                if(chType==1)
                {
                    tv_chName.setText(rowsBean.getChName());
                    SharedPreferences sp = getSharedPreferences("orgId101",
                            Context.MODE_PRIVATE);
                    int signMark = sp.getInt("signMark",0);
                    if(signMark==1)//是否签名
                    {
                        if(rowsBean.getCheckMark()==2)
                        {
                            tv_Notthrough.setVisibility(View.VISIBLE);
                            tv_Notthrough.setImageResource(R.mipmap.bj_21);
                            tv_comple.setImageResource(R.mipmap.bj_11);
                            tv_complesign.setVisibility(View.VISIBLE);
                            record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                            final      String signPicUrl = rowsBean.getSignPicUrl();
                            if(signPicUrl==null)
                            {
                                tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                                record_parent_sign.setText("签名");
                                record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (Utils.isFastDoubleClick()) {
                                            return;
                                        }
                                        int sn =rowsBean.getSn();
                                        Bundle bundle = new Bundle();
                                        bundle.putInt("sn", sn);
                                        bundle.putString("signPicUrl", "");
                                        startActivity(SignActivity.class, bundle);

                                    }
                                });

                            }else{
                                tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                                record_parent_sign.setText("查看签名");
                                record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (Utils.isFastDoubleClick()) {
                                            return;
                                        }
                                        int sn =rowsBean.getSn();
                                        Bundle bundle = new Bundle();
                                        bundle.putInt("sn", sn);
                                        bundle.putString("signPicUrl", signPicUrl);
                                        startActivity(SignActivity.class, bundle);
                                    }
                                });
                            }
                        }else if(rowsBean.getCheckMark()==1)
                        {
                            tv_Notthrough.setVisibility(View.VISIBLE);
                            tv_Notthrough.setImageResource(R.mipmap.bj_09);
                            tv_comple.setImageResource(R.mipmap.bj_11);
                            tv_complesign.setVisibility(View.VISIBLE);
                            record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                            final      String signPicUrl = rowsBean.getSignPicUrl();
                            if(signPicUrl==null)
                            {
                                tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                                record_parent_sign.setText("签名");
                                record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (Utils.isFastDoubleClick()) {
                                            return;
                                        }
                                        int sn =rowsBean.getSn();
                                        Bundle bundle = new Bundle();
                                        bundle.putInt("sn", sn);
                                        bundle.putString("signPicUrl", "");
                                        startActivity(SignActivity.class, bundle);
                                    }
                                });
                            }else{
                                tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                                record_parent_sign.setText("查看签名");
                                record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (Utils.isFastDoubleClick()) {
                                            return;
                                        }
                                        int sn =rowsBean.getSn();
                                        Bundle bundle = new Bundle();
                                        bundle.putInt("sn", sn);
                                        bundle.putString("signPicUrl", signPicUrl);
                                        startActivity(SignActivity.class, bundle);
                                    }
                                });
                            }
                        }else if(rowsBean.getCheckMark()==0)
                        {


                            if(rowsBean.getFinishMark()==1)
                            {
                                tv_comple.setImageResource(R.mipmap.bj_11);
                                tv_Notthrough.setVisibility(View.VISIBLE);
                                tv_Notthrough.setImageResource(R.mipmap.bj_03);
                                tv_complesign.setVisibility(View.VISIBLE);
                                tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                                record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                                record_parent_sign.setText("签名");

                                record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (Utils.isFastDoubleClick()) {
                                            return;
                                        }
                                        int sn =rowsBean.getSn();
                                        Bundle bundle = new Bundle();
                                        bundle.putInt("sn", sn);
                                        bundle.putString("signPicUrl", "");
                                        startActivity(SignActivity.class, bundle);
                                    }
                                });

                            }else if(rowsBean.getFinishMark()==2)
                            {
                                tv_comple.setImageResource(R.mipmap.bj_11);
                                tv_Notthrough.setVisibility(View.VISIBLE);
                                tv_Notthrough.setImageResource(R.mipmap.bj_03);
                                tv_complesign.setVisibility(View.VISIBLE);
                                tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                                record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                                record_parent_sign.setText("查看签名");
                                record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (Utils.isFastDoubleClick()) {
                                            return;
                                        }
                                        int sn =rowsBean.getSn();
                                        String signPicUrl = rowsBean.getSignPicUrl();
                                        Bundle bundle = new Bundle();
                                        bundle.putInt("sn", sn);
                                        bundle.putString("signPicUrl", signPicUrl);
                                        startActivity(SignActivity.class, bundle);
                                    }
                                });

                            }
                            else if(rowsBean.getFinishMark()==0)
                            {
                                tv_comple.setImageResource(R.mipmap.bj_23);
                                tv_Notthrough.setVisibility(View.GONE);
                                tv_complesign.setVisibility(View.GONE);
                                record_parent_sign.setVisibility(View.GONE);

                            }
                        }
                    }else if(signMark==0)
                    {
                        if(rowsBean.getCheckMark()==2)
                        {
                            tv_Notthrough.setVisibility(View.VISIBLE);
                            tv_Notthrough.setImageResource(R.mipmap.bj_21);
                            tv_comple.setImageResource(R.mipmap.bj_11);
                            final      String signPicUrl = rowsBean.getSignPicUrl();
                            if(signPicUrl==null)
                            {
                                tv_complesign.setVisibility(View.GONE);
                                record_parent_sign.setVisibility(View.GONE);//签名按钮
//                            tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
//                            record_parent_sign.setText("签名");
//                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
//                                @Override
//                                public void onClick(View view) {
//                                    if (Utils.isFastDoubleClick()) {
//                                        return;
//                                    }
//                                    int sn =rowsBean.getSn();
//                                    Bundle bundle = new Bundle();
//                                    bundle.putInt("sn", sn);
//                                    bundle.putString("signPicUrl", "");
//                                    startActivity(SignActivity.class, bundle);
//
//                                }
//                            });

                            }else{
                                record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                                tv_complesign.setVisibility(View.VISIBLE);
                                tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                                record_parent_sign.setText("查看签名");
                                record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (Utils.isFastDoubleClick()) {
                                            return;
                                        }
                                        int sn =rowsBean.getSn();
                                        Bundle bundle = new Bundle();
                                        bundle.putInt("sn", sn);
                                        bundle.putString("signPicUrl", signPicUrl);
                                        startActivity(SignActivity.class, bundle);
                                    }
                                });
                            }
                        }else if(rowsBean.getCheckMark()==1)
                        {
                            tv_Notthrough.setVisibility(View.VISIBLE);
                            tv_Notthrough.setImageResource(R.mipmap.bj_09);
                            tv_comple.setImageResource(R.mipmap.bj_11);

                            final      String signPicUrl = rowsBean.getSignPicUrl();
                            if(signPicUrl==null)
                            {
                                tv_complesign.setVisibility(View.GONE);
                                record_parent_sign.setVisibility(View.GONE);//签名按钮
//                            tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
//                            record_parent_sign.setText("签名");
//                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
//                                @Override
//                                public void onClick(View view) {
//                                    if (Utils.isFastDoubleClick()) {
//                                        return;
//                                    }
//                                    int sn =rowsBean.getSn();
//                                    Bundle bundle = new Bundle();
//                                    bundle.putInt("sn", sn);
//                                    bundle.putString("signPicUrl", "");
//                                    startActivity(SignActivity.class, bundle);
//                                }
//                            });
                            }else{
                                tv_complesign.setVisibility(View.VISIBLE);
                                record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                                tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                                record_parent_sign.setText("查看签名");
                                record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (Utils.isFastDoubleClick()) {
                                            return;
                                        }
                                        int sn =rowsBean.getSn();
                                        Bundle bundle = new Bundle();
                                        bundle.putInt("sn", sn);
                                        bundle.putString("signPicUrl", signPicUrl);
                                        startActivity(SignActivity.class, bundle);
                                    }
                                });
                            }
                        }else if(rowsBean.getCheckMark()==0)
                        {
                            if(rowsBean.getFinishMark()==1)
                            {
                                tv_comple.setImageResource(R.mipmap.bj_11);
                                tv_Notthrough.setVisibility(View.VISIBLE);
                                tv_Notthrough.setImageResource(R.mipmap.bj_03);
                                tv_complesign.setVisibility(View.GONE);
                                //      tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                                record_parent_sign.setVisibility(View.GONE);//签名按钮
                                //       record_parent_sign.setText("签名");

//                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
//                                @Override
//                                public void onClick(View view) {
//                                    if (Utils.isFastDoubleClick()) {
//                                        return;
//                                    }
//                                    int sn =rowsBean.getSn();
//                                    Bundle bundle = new Bundle();
//                                    bundle.putInt("sn", sn);
//                                    bundle.putString("signPicUrl", "");
//                                    startActivity(SignActivity.class, bundle);
//                                }
//                            });

                            }else if(rowsBean.getFinishMark()==2)
                            {
                                tv_comple.setImageResource(R.mipmap.bj_11);
                                tv_Notthrough.setVisibility(View.VISIBLE);
                                tv_Notthrough.setImageResource(R.mipmap.bj_03);
                                tv_complesign.setVisibility(View.VISIBLE);
                                tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                                record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                                record_parent_sign.setText("查看签名");
                                record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        if (Utils.isFastDoubleClick()) {
                                            return;
                                        }
                                        String signPicUrl = rowsBean.getSignPicUrl();
                                        int sn =rowsBean.getSn();
                                        Bundle bundle = new Bundle();
                                        bundle.putInt("sn", sn);
                                        bundle.putString("signPicUrl", signPicUrl);
                                        startActivity(SignActivity.class, bundle);
                                    }
                                });

                            }
                            else if(rowsBean.getFinishMark()==0)
                            {
                                tv_comple.setImageResource(R.mipmap.bj_23);
                                tv_Notthrough.setVisibility(View.GONE);
                                tv_complesign.setVisibility(View.GONE);
                                record_parent_sign.setVisibility(View.GONE);

                            }
                        }
                    }
                }else if(chType==3)
                {
                    tv_chName.setText(rowsBean.getChName());
                    if(rowsBean.getCheckMark()==2)
                    {
                        tv_Notthrough.setVisibility(View.VISIBLE);
                        tv_Notthrough.setImageResource(R.mipmap.bj_21);
                        tv_comple.setImageResource(R.mipmap.bj_11);
                        tv_complesign.setVisibility(View.VISIBLE);
                        record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                        final      String signPicUrl = rowsBean.getSignPicUrl();
                        if(signPicUrl==null)
                        {
                            tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                            record_parent_sign.setText("签名");
                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (Utils.isFastDoubleClick()) {
                                        return;
                                    }
                                    int sn =rowsBean.getSn();
                                    Bundle bundle = new Bundle();
                                    bundle.putInt("sn", sn);
                                    bundle.putString("signPicUrl", "");
                                    startActivity(SignActivity.class, bundle);

                                }
                            });

                        }else{
                            tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                            record_parent_sign.setText("查看签名");
                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (Utils.isFastDoubleClick()) {
                                        return;
                                    }
                                    int sn =rowsBean.getSn();
                                    Bundle bundle = new Bundle();
                                    bundle.putInt("sn", sn);
                                    bundle.putString("signPicUrl", signPicUrl);
                                    startActivity(SignActivity.class, bundle);
                                }
                            });
                        }
                    }else if(rowsBean.getCheckMark()==1)
                    {
                        tv_Notthrough.setVisibility(View.VISIBLE);
                        tv_Notthrough.setImageResource(R.mipmap.bj_09);
                        tv_comple.setImageResource(R.mipmap.bj_11);
                        tv_complesign.setVisibility(View.VISIBLE);
                        record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                        final      String signPicUrl = rowsBean.getSignPicUrl();
                        if(signPicUrl==null)
                        {
                            tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                            record_parent_sign.setText("签名");
                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (Utils.isFastDoubleClick()) {
                                        return;
                                    }
                                    int sn =rowsBean.getSn();
                                    Bundle bundle = new Bundle();
                                    bundle.putInt("sn", sn);
                                    bundle.putString("signPicUrl", "");
                                    startActivity(SignActivity.class, bundle);
                                }
                            });
                        }else{
                            tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                            record_parent_sign.setText("查看签名");
                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (Utils.isFastDoubleClick()) {
                                        return;
                                    }
                                    int sn =rowsBean.getSn();
                                    Bundle bundle = new Bundle();
                                    bundle.putInt("sn", sn);
                                    bundle.putString("signPicUrl", signPicUrl);
                                    startActivity(SignActivity.class, bundle);
                                }
                            });
                        }
                    }else if(rowsBean.getCheckMark()==0)
                    {


                        if(rowsBean.getFinishMark()==1)
                        {
                            tv_comple.setImageResource(R.mipmap.bj_11);
                            tv_Notthrough.setVisibility(View.VISIBLE);
                            tv_Notthrough.setImageResource(R.mipmap.bj_03);
                            tv_complesign.setVisibility(View.VISIBLE);
                            tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                            record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                            record_parent_sign.setText("签名");

                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (Utils.isFastDoubleClick()) {
                                        return;
                                    }
                                    int sn =rowsBean.getSn();
                                    Bundle bundle = new Bundle();
                                    bundle.putInt("sn", sn);
                                    bundle.putString("signPicUrl", "");
                                    startActivity(SignActivity.class, bundle);
                                }
                            });

                        }else if(rowsBean.getFinishMark()==2)
                        {
                            tv_comple.setImageResource(R.mipmap.bj_11);
                            tv_Notthrough.setVisibility(View.VISIBLE);
                            tv_Notthrough.setImageResource(R.mipmap.bj_03);
                            tv_complesign.setVisibility(View.VISIBLE);
                            tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                            record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                            record_parent_sign.setText("查看签名");
                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (Utils.isFastDoubleClick()) {
                                        return;
                                    }
                                    int sn =rowsBean.getSn();
                                    String signPicUrl = rowsBean.getSignPicUrl();
                                    Bundle bundle = new Bundle();
                                    bundle.putInt("sn", sn);
                                    bundle.putString("signPicUrl", signPicUrl);
                                    startActivity(SignActivity.class, bundle);
                                }
                            });

                        }
                        else if(rowsBean.getFinishMark()==0)
                        {
                            tv_comple.setImageResource(R.mipmap.bj_23);
                            tv_Notthrough.setVisibility(View.GONE);
                            tv_complesign.setVisibility(View.GONE);
                            record_parent_sign.setVisibility(View.GONE);

                        }
                    }
                }else if(chType==4)
                {
                    tv_chName.setText(rowsBean.getChName());
                    if(rowsBean.getCheckMark()==2)
                    {
                        tv_Notthrough.setVisibility(View.VISIBLE);
                        tv_Notthrough.setImageResource(R.mipmap.bj_21);
                        tv_comple.setImageResource(R.mipmap.bj_11);
                        tv_complesign.setVisibility(View.VISIBLE);
                        record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                        final      String signPicUrl = rowsBean.getSignPicUrl();
                        if(signPicUrl==null)
                        {
                            tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                            record_parent_sign.setText("签名");
                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (Utils.isFastDoubleClick()) {
                                        return;
                                    }
                                    int sn =rowsBean.getSn();
                                    Bundle bundle = new Bundle();
                                    bundle.putInt("sn", sn);
                                    bundle.putString("signPicUrl", "");
                                    startActivity(SignActivity.class, bundle);

                                }
                            });

                        }else{
                            tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                            record_parent_sign.setText("查看签名");
                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (Utils.isFastDoubleClick()) {
                                        return;
                                    }
                                    int sn =rowsBean.getSn();
                                    Bundle bundle = new Bundle();
                                    bundle.putInt("sn", sn);
                                    bundle.putString("signPicUrl", signPicUrl);
                                    startActivity(SignActivity.class, bundle);
                                }
                            });
                        }
                    }else if(rowsBean.getCheckMark()==1)
                    {
                        tv_Notthrough.setVisibility(View.VISIBLE);
                        tv_Notthrough.setImageResource(R.mipmap.bj_09);
                        tv_comple.setImageResource(R.mipmap.bj_11);
                        tv_complesign.setVisibility(View.VISIBLE);
                        record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                        final      String signPicUrl = rowsBean.getSignPicUrl();
                        if(signPicUrl==null)
                        {
                            tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                            record_parent_sign.setText("签名");
                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (Utils.isFastDoubleClick()) {
                                        return;
                                    }
                                    int sn =rowsBean.getSn();
                                    Bundle bundle = new Bundle();
                                    bundle.putInt("sn", sn);
                                    bundle.putString("signPicUrl", "");
                                    startActivity(SignActivity.class, bundle);
                                }
                            });
                        }else{
                            tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                            record_parent_sign.setText("查看签名");
                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (Utils.isFastDoubleClick()) {
                                        return;
                                    }
                                    int sn =rowsBean.getSn();
                                    Bundle bundle = new Bundle();
                                    bundle.putInt("sn", sn);
                                    bundle.putString("signPicUrl", signPicUrl);
                                    startActivity(SignActivity.class, bundle);
                                }
                            });
                        }
                    }else if(rowsBean.getCheckMark()==0)
                    {


                        if(rowsBean.getFinishMark()==1)
                        {
                            tv_comple.setImageResource(R.mipmap.bj_11);
                            tv_Notthrough.setVisibility(View.VISIBLE);
                            tv_Notthrough.setImageResource(R.mipmap.bj_03);
                            tv_complesign.setVisibility(View.VISIBLE);
                            tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
                            record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                            record_parent_sign.setText("签名");

                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (Utils.isFastDoubleClick()) {
                                        return;
                                    }
                                    int sn =rowsBean.getSn();
                                    Bundle bundle = new Bundle();
                                    bundle.putInt("sn", sn);
                                    bundle.putString("signPicUrl", "");
                                    startActivity(SignActivity.class, bundle);
                                }
                            });

                        }else if(rowsBean.getFinishMark()==2)
                        {
                            tv_comple.setImageResource(R.mipmap.bj_11);
                            tv_Notthrough.setVisibility(View.VISIBLE);
                            tv_Notthrough.setImageResource(R.mipmap.bj_03);
                            tv_complesign.setVisibility(View.VISIBLE);
                            tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
                            record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
                            record_parent_sign.setText("查看签名");
                            record_parent_sign.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    if (Utils.isFastDoubleClick()) {
                                        return;
                                    }
                                    int sn =rowsBean.getSn();
                                    String signPicUrl = rowsBean.getSignPicUrl();
                                    Bundle bundle = new Bundle();
                                    bundle.putInt("sn", sn);
                                    bundle.putString("signPicUrl", signPicUrl);
                                    startActivity(SignActivity.class, bundle);
                                }
                            });

                        }
                        else if(rowsBean.getFinishMark()==0)
                        {
                            tv_comple.setImageResource(R.mipmap.bj_23);
                            tv_Notthrough.setVisibility(View.GONE);
                            tv_complesign.setVisibility(View.GONE);
                            record_parent_sign.setVisibility(View.GONE);

                        }
                    }
                }

            }
//            if(rowsBean.getFinishMark()==1)
//            {
//                tv_comple.setImageResource(R.mipmap.bj_11);
////                if(rowsBean.getPjtMark()==1)//判断是否是岗前培训
////                {
////                    tv_complesign.setVisibility(View.GONE);
////                    record_parent_sign.setVisibility(View.GONE);//签名按钮
////
////                }else{
//                    tv_Notthrough.setVisibility(View.VISIBLE);
//                    tv_complesign.setVisibility(View.VISIBLE);
//                    tv_complesign.setImageResource(R.mipmap.bj_112);//未签名
//                    record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
//                    record_parent_sign.setText("签名");
//                    record_parent_sign.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View view) {
//                            if (Utils.isFastDoubleClick()) {
//                                return;
//                            }
//                            int sn =rowsBean.getSn();
//                            Bundle bundle = new Bundle();
//                            bundle.putInt("sn", sn);
//                            startActivity(SignActivity.class, bundle);
//                        }
//                    });
//  //              }
//
//            }else if(rowsBean.getFinishMark()==2)
//            {
//                tv_comple.setImageResource(R.mipmap.bj_11);
////                if(rowsBean.getPjtMark()==1)//判断是否是岗前培训
////                {
////                    tv_complesign.setVisibility(View.GONE);
////                    record_parent_sign.setVisibility(View.GONE);//签名按钮
////                }else {
//                    tv_Notthrough.setVisibility(View.VISIBLE);
//                    tv_complesign.setVisibility(View.VISIBLE);
//                    tv_complesign.setImageResource(R.mipmap.bj_111);//已签名
//                    record_parent_sign.setVisibility(View.VISIBLE);//签名按钮
//                    record_parent_sign.setText("查看签名");
//                    record_parent_sign.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View view) {
//                            if (Utils.isFastDoubleClick()) {
//                                return;
//                            }
//                            String signPicUrl = rowsBean.getSignPicUrl();
//                            Bundle bundle = new Bundle();
//                            bundle.putString("signPicUrl", signPicUrl);
//                            //startActivity(SignCourseActivity.class, bundle);
//                        }
//                    });
//              //  }
//            }
//            else if(rowsBean.getFinishMark()==0)
//            {
//                    tv_comple.setImageResource(R.mipmap.bj_23);
////                if(rowsBean.getPjtMark()==1)//判断是否是岗前培训
////                {
////                    tv_complesign.setVisibility(View.GONE);
////                    record_parent_sign.setVisibility(View.GONE);//签名按钮
////                }else {
//                    tv_Notthrough.setVisibility(View.GONE);
//                    tv_complesign.setVisibility(View.GONE);
//                    record_parent_sign.setVisibility(View.GONE);
//
//            }
            if(rowsBean.getSpotCheckMark()==1)
            {
                tv_checktgrough.setImageResource(R.mipmap.bj_07);
            }else if(rowsBean.getSpotCheckMark()==2)
            {
                tv_checktgrough.setImageResource(R.mipmap.bj_19);
            }else{
                tv_checktgrough.setVisibility(View.INVISIBLE);
            }

            if(b)//判断展开
            {
                if(rowsBean.getListCourse().size()==0)
                {
                    re_nodata.setVisibility(View.VISIBLE);
                }
//                tv_comple.setVisibility(View.VISIBLE);
//                tv_Notthrough.setVisibility(View.VISIBLE);
//                tv_checktgrough.setVisibility(View.VISIBLE);
                img_parent.setImageResource(R.mipmap.jianhao);
//                linearParams.height = 5;// 控件的高强制设成3
//                record_parent_line.setLayoutParams(linearParams);
                record_parent_line.setVisibility(View.GONE);
                gv_parent.setVisibility(View.VISIBLE);
                List<LearnRecordBean.RowsBean.PhotoListBean> photoList = rows.get(parentPos).getPhotoList();
                MyGridViewAdapter gridViewAdapter = new MyGridViewAdapter(SubLearnRecordActivity.this,photoList );
                gv_parent.setAdapter(gridViewAdapter);
             if(rowsBean.getCheckMark()==2)
             {


                 re_des.setVisibility(View.VISIBLE);
                 tv_des.setText(rows.get(parentPos).getCheckDesc());

             }else if(rowsBean.getCheckMark()==1)
             {

                 re_des.setVisibility(View.GONE);

             }else if(rowsBean.getCheckMark()==0)
             {

                 re_des.setVisibility(View.GONE);
             }

            }else{
                re_nodata.setVisibility(View.GONE);
                gv_parent.setVisibility(View.GONE);
                re_des.setVisibility(View.GONE);
//                tv_comple.setVisibility(View.INVISIBLE);
//                tv_Notthrough.setVisibility(View.INVISIBLE);
//                tv_checktgrough.setVisibility(View.INVISIBLE);
                img_parent.setImageResource(R.mipmap.jiahao);
//                linearParams.height = 16;// 控件的高强制设成15
//                record_parent_line.setLayoutParams(linearParams);
                record_parent_line.setVisibility(View.VISIBLE);

            }

            return view;
        }

        //  获得子项显示的view
        @Override
        public View getChildView(int parentPos, int childPos, boolean b, View view, ViewGroup viewGroup) {
            if (view == null) {
                LayoutInflater inflater = (LayoutInflater) SubLearnRecordActivity.this
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = inflater.inflate(R.layout.record_child_item, null);
            }
            view.setTag(R.layout.record_parent_item, parentPos);
            view.setTag(R.layout.record_child_item, childPos);
            TextView tv_courseName =(TextView)view.findViewById(R.id.tv_child);
            TextView tv_creationDate =(TextView)view.findViewById(R.id.tv_child1);
            ImageView tv_muMark =(ImageView)view.findViewById(R.id.tv_child2);
            TextView tv_newlearning =(TextView)view.findViewById(R.id.tv_child5);//从新学习

         final  LearnRecordBean.RowsBean rowsBean = rows.get(parentPos);
         final     LearnRecordBean.RowsBean.ListCourseBean listCourseBean = dataset.get(rowsBean).get(childPos);

            tv_courseName.setText(listCourseBean.getCourseName());
                long creationDate = listCourseBean.getCreationDate();
                String learn="";
                try {
                    //yyyy表示年MM表示月dd表示日
                    //yyyy-MM-dd是日期的格式，比如2015-12-12如果你要得到2015年12月12日就换成yyyy年MM月dd日
                    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
                    //进行格式化
                    learn=sdf.format(creationDate);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                tv_creationDate.setText(learn);
                if(listCourseBean.getMuMark()==1)
                {
                    tv_muMark.setVisibility(View.VISIBLE);
                }else{
                    tv_muMark.setVisibility(View.INVISIBLE);
                }


            if(rowsBean.getCheckMark()==0)//待审核
            {
                int chType = rowsBean.getChType();
                if(chType==2)//线下学习（没有重新学习）
                {
                    tv_newlearning.setVisibility(View.INVISIBLE);
                }else{
                    tv_newlearning.setVisibility(View.VISIBLE);
                }
                tv_newlearning.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if(rowsBean.getPjtMark()==1)//从新学习跳转岗前培训课程
                        {
                            showLoadingDialog("正在加载");
                            int utchSn = rowsBean.getSn();
                            int sn1 = listCourseBean.getSn();
                            int tcSn = listCourseBean.getTcSn();
                            SharedPreferences sp = getSharedPreferences("orgId101",
                                    Context.MODE_PRIVATE);
                            int pjtMinPer = sp.getInt("pjtMinPer", 0);
                            Bundle bundle = new Bundle();
                            bundle.putInt("utchSn",utchSn);
                            bundle.putInt("sn",sn1);
                            bundle.putInt("tcSn",tcSn);
                            bundle.putInt("pjtMinPer",pjtMinPer);
                            startActivity(NewPrejobCourseDetailsActivity.class, bundle);

                        }else{//课程超市和指定学习从新学习
                            showLoadingDialog("正在加载");
                            int utchSn = rowsBean.getSn();
                            int sn2 = listCourseBean.getSn();
                            int tcSn = listCourseBean.getTcSn();
                            int chType = rowsBean.getChType();
                            SharedPreferences sp = getSharedPreferences("orgId101",
                                    Context.MODE_PRIVATE);
                            int minPer = sp.getInt("minPer", 0);
                            int photoMark = sp.getInt("photoMark", 0);
                            if(chType==1)
                            {

                                Bundle bundle = new Bundle();
                                bundle.putInt("utchSn",utchSn);
                                bundle.putInt("sn",sn2);
                                bundle.putInt("tcSn",tcSn);
                                bundle.putInt("minPer",minPer);
                                bundle.putInt("photoMark",photoMark);
                                startActivity(NewSpecifiedAndCourseDetailsActivity.class, bundle);
                            }else if(chType==3)//单位人员
                            {
                                Bundle bundle = new Bundle();
                                bundle.putInt("sn",sn2);
                                bundle.putInt("tcSn",tcSn);
                                bundle.putInt("minPer",minPer);
                                startActivity(NewSpecifiedAndCourseBusinessDetailsActivity.class, bundle);
                            }else if(chType==4)//企业管理人员
                            {
                                Bundle bundle = new Bundle();
                                bundle.putInt("sn",sn2);
                                bundle.putInt("tcSn",tcSn);
                                bundle.putInt("minPer",minPer);
                                startActivity(NewSpecifiedAndCourseBusinessDetailsActivity.class, bundle);
                            }
                        }
                    }
                });


            }
            else{
                tv_newlearning.setVisibility(View.INVISIBLE);
            }



            return view;
        }

        //  子项是否可选中，如果需要设置子项的点击事件，需要返回true
        @Override
        public boolean isChildSelectable(int i, int i1) {
            return true;
        }
    }
}
